#pragma once
#include<Socket.h>
class SocketTCP:public Socket{
    protected:
    public:
    virtual int SockStartup();
    virtual int send(SockBuffer* buf);
    virtual int recv(SockBuffer* buf);
    SocketTCP():Socket(){SockStartup();}
    SocketTCP(const char* addr,int port):Socket(addr,port){SockStartup();}
};

int SocketTCP::SockStartup(){
    if(Sock){
        closesocket(Sock);
    }
    Sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (Sock == INVALID_SOCKET){
        err = 2;            //异常处理
        return err;
    }
}

int SocketTCP::send(SockBuffer* buf){
    ::send(Sock,buf->buffer,buf->len,0);
}

int SocketTCP::recv(SockBuffer* buf){
    ::recv(Sock,buf->buffer,buf->len,0);
}

SocketTCP * makeSocketTCP(const char* addr,int port){
    return new SocketTCP(addr,port);
}

SocketTCP * makeSocketTCP(){
    return new SocketTCP();
}